drop: --fast support when dropping from a remote
authorJoey Hess <joeyh@joeyh.name>
Fri, 29 Aug 2025 16:45:33 +0000 (12:45 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 29 Aug 2025 16:45:33 +0000 (12:45 -0400)
This is the same as --not --in $remote, but easier to type. And the
documentation of --fast helps also document that drop can do extra work
when used without --fast.

Sponsored-by: Nicholas Golder-Manning
CHANGELOG
Command/Drop.hs
doc/git-annex-drop.mdwn
doc/todo/drop_--from_unnecessary_locking_of_files_not_in_remote.mdwn

index 34d9e65c91bf4d02f57e8947f4a7a2eaeee35117..dfd780321a7f9e193743f1d705f387d453150f24 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+git-annex (10.20250829) UNRELEASED; urgency=medium
+
+  * drop: --fast support when dropping from a remote.
+
+ -- Joey Hess <id@joeyh.name>  Fri, 29 Aug 2025 12:34:06 -0400
+
 git-annex (10.20250828) upstream; urgency=medium
 
   * p2p: Added --enable option, which can be used to enable P2P networks
index 94720a6ae40c9d9ad4c8d0eade07778c28ce7221..2f27da92dcb17ce8326c409f2593af5b2121a4c1 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex command
  -
- - Copyright 2010-2021 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2025 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -109,8 +109,17 @@ startLocal lu pcc afile ai si numcopies mincopies key preverified ud =
                performLocal lu pcc key afile numcopies mincopies preverified ud
 
 startRemote :: LiveUpdate -> PreferredContentChecked -> AssociatedFile -> ActionItem -> SeekInput -> NumCopies -> MinCopies -> Key -> DroppingUnused -> Remote -> CommandStart
-startRemote lu pcc afile ai si numcopies mincopies key ud remote = 
-       starting "drop" (OnlyActionOn key ai) si $ do
+startRemote lu pcc afile ai si numcopies mincopies key ud remote = do
+       fast <- Annex.getRead Annex.fast
+       if fast
+               then do
+                       remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
+                       if remote `elem` remotes
+                               then go
+                               else stop
+               else go
+  where
+       go = starting "drop" (OnlyActionOn key ai) si $ do
                showAction $ UnquotedString $ "from " ++ Remote.name remote
                performRemote lu pcc key afile numcopies mincopies remote ud
 
index aa66696958fcac10f081c480fab803b24f3b0afc..3d1307700a10378213648df59521cd279e22748b 100644 (file)
@@ -42,6 +42,13 @@ Paths of files or directories to drop can be specified.
   this option can specify a remote from which the files'
   contents should be removed.
 
+* `--fast`
+
+  When dropping from a remote, avoid doing anything when the remote is not
+  believed to contain a file. Usually each file is attempted to be dropped
+  from the remote. This can be faster, but might leave some files on the
+  remote in some cases.
+
 * `--auto`
 
   Rather than trying to drop all specified files, drop only those that
index ac4b455a75e8e3b84bbbb72497c5bbcfb044aeeb..cedb23572c646df0f91f4f2775c2658667788f49 100644 (file)
@@ -8,11 +8,15 @@ Using `git-annex drop --from foo --in foo` avoided the problem.
 
 The reason drop behaves this way is that it's intended to
 remove content from a remote even when the local repository's location log
-is out of sync with it. Still, it's somewhat surprising and annoying that
-it can need to do so much extra work.
+is out of sync with it. In order to avoid the surprising behavior of
+`git-annex drop foo` saying it succeeded, in a case where it turns out the
+remote just recently got the file. Still, it's somewhat surprising too, and
+annoying, that it can need to do so much extra work.
 
 Note that checking if the remote actually has the content would be about as
 slow as locking files on the other remote(s) (assuming a small numcopies).
 
 `--fast` could be made to deal with this, making it check the location log.
 --[[Joey]]
+
+> [[done]]